package com.beimihu.leetcode;

public class LessCandy {
    public int candy(int[] ratings) {
        int[] candyCount = new int[ratings.length];
        for (int i = 0; i < candyCount.length; i++) {
            candyCount[i] = 1;
        }

        for(int i = 1 ; i < ratings.length ; i++){
            if(ratings[i - 1] < ratings[i]){
                candyCount[i] = ratings[i-1] + 1;
            }
        }

        int res = 0;
        for(int i = 0 ; i < candyCount.length-1 ; i++){
            res = res + candyCount[i];
        }
        return res;

    }
}
